const EventEmitter = require('events');
const util = require('util');

function MyEmitter() {
    EventEmitter.call(this);
}
util.inherits(MyEmitter, EventEmitter);

const myEmitter = new MyEmitter();
myEmitter.on('event', (a, b) => {
    console.log('Synchronous A');
});
myEmitter.on('event', (a, b) => {
    console.log('Synchronous B');
});
myEmitter.on('event', (a, b) => {
    setImmediate(() => {
        console.log('Asynchronous A');
    });
})
myEmitter.on('event', (a, b) => {
    setImmediate(() => {
        console.log('Asynchronous B');
    });
});
myEmitter.emit('event');
